<template>
  <div class="non-trace-form-item">

    <el-form ref="ruleForm" :label-position="'top'" label-width="80px" :model="formLabelAlign" >

      <SkyPanel title="开户银行信息" id="first">

        <template v-slot:header>
          <img style="width:16px" src="~@/assets/images/panel-error.png" alt="">
          <span>（至少添加一条银行账号信息用于后续业务）</span>
        </template>

        <template v-slot:main>

          <div class="module-container" v-for="(item,index)   in formLabelAlign.bankInformation" :key="index">
            <div class="module-header-container">
              <div>银行信息{{index+1}}</div>
              <div></div>
            </div>
            <div class="module-main-container">
              <el-row :gutter="20">
                <el-col :span="8">
                  <el-form-item prop="key1" label="开户银行" :rules="[
                    { required: true, message: '请输入开户银行', trigger: 'blur' },
                  ]">
                    <el-input v-model="item.key1"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item  prop="key2" label="银行账号" :rules="[
                    { required: true, message: '请输入银行账号', trigger: 'blur' },
                  ]">
                    <el-input v-model="item.key2"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item prop="key3" label="账号名称" :rules="[
                    { required: true, message: '请输入账号名称', trigger: 'blur' },
                  ]">
                    <el-input v-model="item.key3"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row :gutter="20">
                <el-col :span="8">
                  <el-form-item prop="key4" label="联行号" :rules="[
                    { required: false, message: '请输入联行号', trigger: 'blur' },
                  ]">
                    <el-input v-model="item.key4"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item   label="启用状态" :rules="[
                    { required: false, message: '请选择启用状态', trigger: 'blur' },
                  ]">
                    <el-switch v-model="item.key5" active-color="#1890FF" inactive-color="#f2f2f2" active-value="1" inactive-value="0">
                    </el-switch>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="主账号" :rules="[
                    { required: false, message: '请输入', trigger: 'blur' },
                  ]">
                    <el-switch v-model="item.key6" active-color="#1890FF" inactive-color="#f2f2f2" active-value="1" inactive-value="0">
                    </el-switch>
                  </el-form-item>
                </el-col>
              </el-row>

            </div>
          </div>

          <div class="module-add">
            <img src="~@/assets/images/module-add.png" alt="">
            <span>新增开户银行</span>
          </div>

        </template>
      </SkyPanel>

      <SkyPanel title="近三年财务状况" id="two">
        <template v-slot:main>
          <div class="uploader">
            <el-form-item prop="key7" label="最近三年经审计财务报表" :rules="[
                { required: true, message: '请选择财务报表', trigger: 'blur' },
              ]">
            <el-upload class="upload-demo" action="https://jsonplaceholder.typicode.com/posts/" :on-change="handleChange" >
              <el-button size="small" plain>上传附件</el-button>
            </el-upload>
          </el-form-item>
          </div>
          

        </template>
      </SkyPanel>

      <SkyPanel title="资信证明" id="three">
        <template v-slot:main>
          <el-input  type="textarea"  v-model="formLabelAlign.desc"></el-input>
          <div class="uploader">
              <el-form-item  prop="key8" label="资信附件 " :rules="[
                  { required: true, message: '请上传资信附件', trigger: 'blur' },
                ]">
              <el-upload class="upload-demo" action="https://jsonplaceholder.typicode.com/posts/" :on-change="handleChange2" >
                <el-button size="small" plain>上传附件</el-button>
              </el-upload>
            </el-form-item>
          </div>
         

        </template>
      </SkyPanel>

    </el-form>

  </div>
  <div>
    <SkyPanelPositionGroup scrolltop='150' offsettop='150'>
      <SkyPanelPositionUnit prop="first" label="开户银行信息"></SkyPanelPositionUnit>
      <SkyPanelPositionUnit prop="two" label="近三年财务状况"></SkyPanelPositionUnit>
      <SkyPanelPositionUnit prop="three" label="资信证明"></SkyPanelPositionUnit>
    </SkyPanelPositionGroup>
  </div>
  <div class="footer">
    <el-button  @click="prestep">上一步</el-button>
    <el-button type="primary"  @click="submitForm('ruleForm')">保存</el-button>
    <el-button type="primary" @click="next">下一步</el-button>
  </div>
</template>


<script lang="ts">
  import { defineComponent } from "vue";

  export default defineComponent({
    data() {
      return {
        key7:"",
        key8:"",
        formLabelAlign: {
          desc: "",
          bankInformation: [
            {
              key1: "",
              key2: "",
              key3: "",
              key4: "",
              key5: "",
              key6: "",
            },
            {
              key1: "",
              key2: "",
              key3: "",
              key4: "",
              key5: "",
              key6: "",
            },

          ],
          fileList: [
            {
              name: "food.jpeg",
              url:
                "https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100",
            },
            {
              name: "food2.jpeg",
              url:
                "https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100",
            },
          ],
          fileList2: [
            {
              name: "food.jpeg",
              url:
                "https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100",
            },
            {
              name: "food2.jpeg",
              url:
                "https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100",
            },
          ],
        },
      };
    },
    methods: {
      handleChange(file, fileList) {
        this.fileList = fileList.slice(-3);
      },
      handleChange2(file, fileList) {
        this.fileList = fileList.slice(-3);
      },
      prestep(){
       this.$parent.active = 1;
      },
      next() {
        this.$parent.active = 3;
      },
      submitForm(formName){
        this.$refs[formName].validate((vaid)=>{
          if(vaid){
            alert('submit!')
          }else{
            alert("error submit")
            console.log("error submit")
            return false
          }
        })
      },
    },
    // setup() {},
  });
</script>


<style lang="scss" scoped>
/**
 *表单样式
 */
.non-trace-form-item {
  /deep/ .el-form-item__label {
    line-height: 30px;
    padding: 0 0 5px;
  }
  /deep/ .el-input__inner {
    outline: none;
    border: none;
  }
  /deep/ .el-form-item__content {
    border-bottom: 1px solid #dcdcdc;
  }
}

.module-container {
  width: 100%;
  min-height: 100px;
  background: #f6f8fa;
  padding: 0 20px;
  margin-bottom: 20px;
  .module-header-container {
    display: flex;
    align-items: center;
    padding: 14px 0px;
    & > div:nth-child(1) {
      height: 28px;
      font-size: 20px;
      font-family: PingFang SC;
      font-weight: bold;
      line-height: 28px;
      color: #333333;
      opacity: 1;
    }
    & > div:nth-child(2) {
      flex: 1;
      border-bottom: 1px dashed #dcdcdc;
      height: 1px;
      margin: 0 10px;
    }
    & > div:nth-child(3) {
      height: 22px;
      font-size: 16px;
      font-family: PingFang SC;
      font-weight: 500;
      line-height: 22px;
      color: #1890ff;
      opacity: 1;
      cursor: pointer;
    }
  }

  /deep/ .el-input__inner {
    background: #f6f8fa !important;
    background-color: #f6f8fa !important;
  }
}

.module-add {
  display: flex;
  line-height: 50px;
  align-items: center;
  color: #1890ff;
  cursor: pointer;
  & > img {
    width: 20px;
    height: 20px;
    margin-right: 5px;
  }
}

.footer {
  height: 60px;
  width: 1164px;
  position: fixed;
  bottom: 0;
  background: white;
  z-index: 10;
  text-align: right;
  line-height: 60px;
}

.uploader{
  /deep/ .el-form-item__label {
    line-height: 30px;
    padding: 0 0 5px;
  }
  /deep/ .el-input__inner {
    outline: none;
    border: none;
  }
  /deep/ .el-form-item__content {
    border-bottom: none;
  }
  /deep/ .el-button {
    width: 138px;
    height: 44px;
  }
}
</style>